home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility1 / gs261src.zip / GDEVPCFB.H < prev    next >
C/C++ Source or Header  |  1993-05-19  |  6KB  |  169 lines

  1. /* Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gdevpcfb.h */
  20. /* IBM PC frame buffer definitions for Ghostscript */
  21. #include "dos_.h"
  22. typedef union REGS registers;
  23.  
  24. /* For testing, the 16-color display may be defined as a monochrome, */
  25. /* 8-color, or 16-color device. */
  26. #define ega_bits_of_color 2        /* 0, 1, or 2 */
  27.  
  28. /* Range of r-g-b values */
  29. #define rgb_max ega_bits_of_color
  30.  
  31. #ifndef USE_ASM
  32. #  define USE_ASM 0            /* don't use assembly language */
  33. #endif
  34.  
  35. /* Define the short (integer) version of "transparent" color. */
  36. /* ****** Depends on gx_no_color_index being all 1's. ******/
  37. #define no_color ((int)gx_no_color_index)
  38.  
  39. /* Procedures */
  40.  
  41.     /* See gxdevice.h for the definitions of the procedures. */
  42.  
  43. extern dev_proc_open_device(ega_open);
  44. extern dev_proc_close_device(ega_close);
  45. extern dev_proc_map_rgb_color(ega_map_rgb_color);
  46. extern dev_proc_map_color_rgb(ega_map_color_rgb);
  47. extern dev_proc_fill_rectangle(ega_fill_rectangle);
  48. extern dev_proc_tile_rectangle(ega_tile_rectangle);
  49. extern dev_proc_copy_mono(ega_copy_mono);
  50. extern dev_proc_copy_color(ega_copy_color);
  51. extern dev_proc_get_bits(ega_get_bits);
  52.  
  53. /* Procedures used by gdevpcfb.c */
  54. extern void ega_set_signals(P1(gx_device *));
  55. extern int ega_get_mode(P0());
  56. extern void ega_set_mode(P1(int));
  57.  
  58. /* Types for frame buffer pointers. */
  59. typedef byte *fb_ptr;
  60. typedef volatile byte *volatile_fb_ptr;
  61.  
  62. /* Define the nominal page height in inches. */
  63. #ifdef A4
  64. #  define PAGE_HEIGHT_INCHES 11.0
  65. #else
  66. #  define PAGE_HEIGHT_INCHES 11.69
  67. #endif
  68.  
  69. /* The device descriptor */
  70. typedef struct gx_device_ega_s gx_device_ega;
  71. struct gx_device_ega_s {
  72.     gx_device_common;
  73.     int raster;            /* frame buffer bytes per line */
  74.     int fb_seg_mult;        /* multiplier for segment part */
  75.                     /* of frame buffer pointer */
  76.     int fb_byte_mult;        /* multiplier for word part ditto */
  77. #define mk_fb_ptr(x, y)\
  78.   (fb_dev->fb_byte_mult == 0 ?\
  79.    (fb_ptr)MK_PTR(regen + (y) * (fb_dev->fb_seg_mult), (x) >> 3) :\
  80.    (fb_ptr)MK_PTR(regen + ((y) >> 4) * (fb_dev->fb_seg_mult),\
  81.          (((y) & 15) * fb_dev->fb_byte_mult) + ((x) >> 3)))
  82.     int video_mode;
  83. };
  84.  
  85. /* Macro for creating instances */
  86. /* The initial parameters map an appropriate fraction of */
  87. /* the screen to a full-page coordinate space. */
  88. /* This may or may not be what is desired! */
  89. #define ega_device(dev_name, procs, fb_raster, screen_height, aspect_ratio, video_mode)\
  90.    {    sizeof(gx_device_ega),\
  91.     &procs,\
  92.     dev_name,\
  93.     fb_raster * 8, screen_height,\
  94.       (screen_height * (aspect_ratio)) / PAGE_HEIGHT_INCHES,    /* x dpi */\
  95.       screen_height / PAGE_HEIGHT_INCHES,        /* y dpi */\
  96.     no_margins,\
  97.        {    (rgb_max ? 3 : 1),    /* num_components */\
  98.         4,            /* depth */\
  99.         (rgb_max ? rgb_max : 1),    /* gray_max */\
  100.         rgb_max,\
  101.         3,            /* dither_gray */\
  102.         (rgb_max ? rgb_max + 1 : 0)    /* dither_rgb */\
  103.        },\
  104.     0,            /* not opened yet */\
  105.     fb_raster,\
  106.     (fb_raster & 15 ? fb_raster : fb_raster >> 4),\
  107.     (fb_raster & 15 ? fb_raster : 0),\
  108.     video_mode\
  109.    }
  110.  
  111. /* Define the device port and register numbers, and the regen map base */
  112. #define seq_addr 0x3c4
  113. #define s_map 2
  114. #define set_s_map(mask) outport2(seq_addr, s_map, mask)
  115. #define graph_addr 0x3ce
  116. #define g_const 0            /* set/reset */
  117. #define set_g_const(color) outport2(graph_addr, g_const, color)
  118. #define g_const_map 1            /* enable set/reset */
  119. #define set_g_const_map(map) outport2(graph_addr, g_const_map, map)
  120. #define g_function 3
  121. #  define gf_WRITE 0
  122. #  define gf_AND 8
  123. #  define gf_OR 0x10
  124. #  define gf_XOR 0x18
  125. #define set_g_function(func) outport2(graph_addr, g_function, func)
  126. #define g_read_plane 4
  127. #define set_g_read_plane(plane) outport2(graph_addr, g_read_plane, plane)
  128. #define g_mode 5
  129. #  define gm_DATA 0
  130. #  define gm_FILL 2
  131. #define set_g_mode(mode) outport2(graph_addr, g_mode, mode)
  132. #define g_mask 8
  133. #define set_g_mask(mask) outport2(graph_addr, g_mask, mask)
  134. #define select_g_mask() outportb(graph_addr, g_mask)
  135. #define out_g_mask(mask) outportb(graph_addr+1, mask)
  136. #define regen 0xa000
  137.  
  138. /* Define access to the frame buffer and the video registers */
  139. /* according to whether we are on a DOS system or a Unix system. */
  140.  
  141. #if defined(M_UNIX) || defined(M_XENIX) || defined(UNIX) || defined(SYSV)
  142.  
  143.         /* SCO Unix/Xenix or AT&T SVR4. */
  144.  
  145. #undef outportb
  146. extern void outportb(P2(uint, byte));
  147. extern void outport2(P3(uint, byte, byte));
  148.  
  149. /* Redefine mk_fb_ptr -- no segmented addressing. */
  150.  
  151. #undef mk_fb_ptr
  152. extern fb_ptr fb_addr;
  153. #define mk_fb_ptr(x, y)    (fb_addr + (y) * (fb_dev->raster) + ((x) >> 3))
  154.  
  155. #else
  156.  
  157.         /* MS-DOS */
  158.  
  159. /* outportb is defined in dos_.h */
  160. #define outport2(port, index, data)\
  161.   (outportb(port, index), outportb((port)+1, data))
  162.  
  163. #endif
  164.  
  165. /* Fetch and discard a byte.  Prevent the compiler from */
  166. /* optimizing this away. */
  167. static unsigned char byte_discard_;
  168. #define byte_discard(expr) byte_discard_ = (expr)
  169.